package day_02;

/**
 * 在有序的数组中快速找的两数之和等于target的位置
 */
public class leetcode_167 {
    public int[] twoSum(int[] numbers, int target) {
        int left=0;
        int right=numbers.length;
        for(int i=0;left!=right;i++)
        {
            if(numbers[right-1]==target-numbers[left])
                return new int[] {left,right};
            else if(numbers[right-1]>target-numbers[left])
                right--;
            else if(numbers[right-1]<target-numbers[left])
                left++;
        }
        return new int[] {-1,-1};
    }
}
